/**
 * Title: Hyperbolic engine
 * Description: jFamilyTree Engine
 * Version: provider
 * Copyright: (c) 2001-2008
 * Terms of use:see license agreement at http://treebolic.sourceforge.net/en/license.htm
 * Author: Bernard Bou
 * Company: bsys
 * Update: Mon Mar 10 00:00:00 CEST 2008
 */
package jFamilyTree.model;

import java.awt.Color;
import java.awt.Image;

/**
 * Edge data
 * 
 * @author Bernard Bou
 */
class EdgeData
{
	/**
	 * Label
	 */
	protected String theLabel;

	/**
	 * Edge color
	 */
	protected Color theColor;

	/**
	 * Edge style
	 */
	protected Integer theStyle;

	/**
	 * Edge image filename
	 */
	protected String theImageFile;

	/**
	 * Constructor
	 */
	public EdgeData()
	{
		theLabel = null;
		theColor = null;
		theStyle = null;
		theImageFile = null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.kernel.IEdge#getLabel()
	 */
	public String getLabel()
	{
		return theLabel;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.kernel.IEdge#getColor()
	 */
	public Color getColor()
	{
		return theColor;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.kernel.IEdge#getStyle()
	 */
	public Integer getStyle()
	{
		return theStyle;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.kernel.IEdge#getImageFile()
	 */
	public String getImageFile()
	{
		return theImageFile;
	}
}

/**
 * Extended edge data (internal use)
 * 
 * @author Bernard Bou
 */
class XEdgeData extends EdgeData
{
	/**
	 * Edge image
	 */
	protected Image theImage;

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.kernel.IEdge#getImage()
	 */
	public Image getImage()
	{
		return theImage;
	}

	/**
	 * Set image
	 * 
	 * @param thisImage
	 *        image
	 */
	public void setImage(Image thisImage)
	{
		theImage = thisImage;
	}
}

/**
 * Edge
 * 
 * @author Bernard Bou
 */
public class Edge extends XEdgeData implements IEdge
{
	/**
	 * From-node
	 */
	protected INode theFromNode;

	/**
	 * To-node
	 */
	protected INode theToNode;

	/**
	 * Construct edge
	 * 
	 * @param thisFromINode
	 *        from node
	 * @param thisToINode
	 *        to node
	 */
	public Edge(INode thisFromINode, INode thisToINode)
	{
		super();
		theFromNode = thisFromINode;
		theToNode = thisToINode;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.kernel.IEdge#getFrom()
	 */
	public INode getFrom()
	{
		return theFromNode;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.kernel.IEdge#getTo()
	 */
	public INode getTo()
	{
		return theToNode;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	public String toString()
	{
		return (theFromNode == null ? "null" : theFromNode.getLabel()) + "->" + (theToNode == null ? "null" : theToNode.getLabel());
	}
}
